package com.wanmait.hr.service.Impl;

import com.wanmait.hr.mapper.RegulationsMapper;
import com.wanmait.hr.service.RegulationsService;
import com.wanmait.hr.util.Pager;
import com.wanmait.hr.vo.Department;
import com.wanmait.hr.vo.Regulations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * RegulationsService interface
 *
 * @author 王志斌
 * @date 2019-01-28
 * */

@Service("RegulationsService")
public class RegulationsServiceImpl implements RegulationsService {

    @Resource
    private RegulationsMapper regulationsMapper;

    /**新增部门时上传规章制度_王志斌
     * @param html
     * @param departId
     * @param adminId
     * */
    @Override
    public void insertDepartRegulation(String html, Integer departId, Integer adminId) {
        regulationsMapper.insertDepartRegulation(html, departId, adminId);
    }

    /**修改部门时根据部门id查找部门规章制度
     * @param departId
     * @return String queryTheRegulationByDepartId
     * */
    @Override
    public String queryTheRegulationByDepartId(Integer departId) {
        String regulation = regulationsMapper.queryTheRegulationByDepartId(departId);
        if(regulation == null)
        {
            regulation = "";
        }
        return regulation;
    }

    /**修改部门时修改部门的规章制度
     * @param info
     * @param departId
     * */
    @Override
    public void updateDepartRegulation(String info, Integer departId, Integer updateAdminId) {
        regulationsMapper.updateDepartRegulation(info, departId, updateAdminId);
    }

    @Override
    public Regulations topManagerRegulation() { //总经理的规章制度
        return regulationsMapper.topManagerRegulation();
    }

    @Override
    public List<Regulations> departmentManagerRegulation(Department department) { //部门经理的规章制度
        return regulationsMapper.departmentManagerRegulation(department);
    }

    /**查看个人信息时获取登陆用户的部门规章制度
     * @param departId
     * @param pager
     * @return List<Regulations>
     * */
    @Override
    public List<Regulations> getRegulationsByDepartment(Integer departId, Pager pager) {
        return regulationsMapper.getRegulationsByDepartment(departId, pager);
    }

    /**查看个人信息时获取登陆用户的部门规章制度总条数
     * @param departId
     * @return Integer
     * */
    @Override
    public Integer dateCountByDepartId(Integer departId) {
        Integer dateCount = regulationsMapper.dateCountByDepartId(departId);

        if(dateCount == null || dateCount < 1)
        {
            dateCount = 1;
        }
        return dateCount;
    }

    @Override
    public List<Regulations> findAll() {
        return null;
    }

    @Override
    public List<Regulations> findAll(Regulations object) {
        return null;
    }

    @Override
    public Regulations findById(Integer id) {
        return null;
    }

    @Override
    public void insert(Regulations object) {

    }

    @Override
    public void update(Regulations object) {

    }

    @Override
    public void delete(int id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    public int getDataCount() {
        return 0;
    }

    @Override
    public int getDataCount(Regulations object) {
        return 0;
    }
}
